function  [policy, value] = plotValuePolicy()
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
d0 = load('policy.txt');
v0 = load('value.txt');

nT = 400;
size = 10000;

policy = zeros(size,nT);
value = zeros(size,nT);

for t = 1 : nT
    len = t + 1;
    binSize = floor(size / len);
    for s = 1 : len
        value( (1 + (s-1)*binSize):(s*binSize), t) = v0(t,s);
    end
    value((len*binSize):end, t) = v0(t,t+1);
    leftB = floor(( 1 - d0(t,3) ) / 2 * size) + 1;
    rightB = ceil(( 1 + d0(t,3) ) / 2 * size);
    policy(1 : (leftB - 1),t) = 1; %left
    policy(leftB : rightB,t) = 3; %Sample
    policy((rightB+1):end,t) = 2; %right;
end


figure('Colormap',...
    [0 0 0.5625;0 0 0.579999983310699;0 0 0.597500026226044;0 0 0.615000009536743;0 0 0.632499992847443;0 0 0.649999976158142;0 0 0.667500019073486;0 0 0.685000002384186;0 0 0.702499985694885;0 0 0.720000028610229;0 0 0.737500011920929;0 0 0.754999995231628;0 0 0.772499978542328;0 0 0.790000021457672;0 0 0.807500004768372;0 0 0.824999988079071;0 0 0.842499971389771;0 0 0.860000014305115;0 0 0.877499997615814;0 0 0.894999980926514;0 0 0.912500023841858;0 0 0.930000007152557;0 0 0.947499990463257;0 0 0.964999973773956;0 0 0.982500016689301;0 0 1;0 0.0909090936183929 1;0 0.181818187236786 1;0 0.272727280855179 1;0 0.363636374473572 1;0 0.454545468091965 1;0 0.545454561710358 1;0 0.636363625526428 1;0 0.727272748947144 1;0 0.818181812763214 1;0 0.909090936183929 1;0 1 1;0.100000001490116 0.984313726425171 0.899999976158142;0.200000002980232 0.968627452850342 0.800000011920929;0.300000011920929 0.952941179275513 0.699999988079071;0.400000005960464 0.937254905700684 0.600000023841858;0.5 0.921568632125854 0.5;0.600000023841858 0.905882358551025 0.400000005960464;0.699999988079071 0.890196084976196 0.300000011920929;0.800000011920929 0.874509811401367 0.200000002980232;0.899999976158142 0.858823537826538 0.100000001490116;1 0.843137264251709 0;1 0.632352948188782 0;1 0.421568632125854 0;1 0.210784316062927 0;1 0 0;0.961538434028625 0 0;0.923076927661896 0 0;0.884615361690521 0 0;0.846153855323792 0 0;0.807692289352417 0 0;0.769230782985687 0 0;0.730769217014313 0 0;0.692307710647583 0 0;0.653846144676208 0 0;0.615384638309479 0 0;0.576923072338104 0 0;0.538461565971375 0 0;0.5 0 0]);
image(1:nT, (1:size)/size,  value);
ylabel('$\hat{\mu}$','FontWeight', 'bold','FontSize',48,'Interpreter','latex');
xlabel('t','FontWeight', 'bold','FontSize',48);
colorbar();
set(gca, 'LineWidth',2,'FontSize',48,...
    'FontWeight','bold','XTick',[100 200 300 400], 'YTick',[0.25 0.5 0.75 1]);
set(gcf,'paperunits','inches');
set(gcf,'papersize',[15 15]);
set(gcf,'paperposition',[0,0,15,15]);
saveas(gcf,'value.fig','fig');
saveas(gcf,'value.jpg','jpg');

figure;
image( 1:nT, (1:size)/size, policy * 8);
colormap('lines');
ylabel('\mu','FontWeight', 'bold','FontSize',48);
xlabel('m','FontWeight', 'bold','FontSize',48);
set(gca, 'LineWidth',2,'FontSize',48,...
    'FontWeight','bold','XTick',[100 200 300 400], 'YTick',[0.25 0.5 0.75 1]);
set(gcf,'paperunits','inches');
set(gcf,'papersize',[15 15]);
set(gcf,'paperposition',[0,0,15,15]);
saveas(gcf,'policy.fig','fig');
saveas(gcf,'policy.jpg','jpg');
end

